export default {
    setData(name,data){
          let dataType = typeof data;
          if (dataType === 'object') {
              window.localStorage.setItem(name,JSON.stringify(data));
          }
          else if (['number','string','boolean'].indexOf(dataType)>=0 ) {
              window.localStorage.setItem(name,data);
          }
          else {
              console.log('This type is not suitable for local storage');
          }
     },
     getData(name){
         let data=window.localStorage.getItem(name);
         if (data) {
             return JSON.parse(data);
         }
         else {
             return '';
         }
     },
     removeData(name) {
         return window.localStorage.removeItem(name);
     },
     clearAllData() {
         return window.localStorage.clear();
     }
}   